export default{
	state:{
		// 登录状态
		loginStatus:false,
		// sessionKey
		sessionKey:null
	},
	mutations:{
		// 初始化登录状态
		initUser(state){
			let sessionKey = uni.getStorageSync('sessionKey')
			if (sessionKey) {
				state.sessionKey = sessionKey
				state.loginStatus = true
			}
		},
		// 登录
		login(state,sessionKey){
			state.loginStatus = true
			state.sessionKey = sessionKey
			// 持久化存储
			uni.setStorageSync('sessionKey', sessionKey)
		},
		// 退出登录
		logout(state){
			state.loginStatus = false
			state.sessionKey = null
			uni.removeStorageSync('sessionKey')
		}
	}
}